<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>$apply和$digest方法</title>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<div ng-bind="name"></div>
</body>
</html>

<script src="../libs/AngularJS.min.js"></script>
<script>
    angular
        .module('myApp', [])
        .controller('myCtrl', ['$scope', function ($scope) {
            $scope.name = new Date().toLocaleString();

//            setInterval(function () {
//                // 这里虽然变了，但是没有触发 脏检查来改变页面上的值
//                $scope.name = new Date().toLocaleString();
//            },1000)

            setInterval(function () {
                $scope.$apply(function () {
                    $scope.name = new Date().toLocaleString();
                });
            }, 1000)
        }]);
</script>